//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.liy.framework.web.spring.controller;

import com.liy.framework.common.extvo.LoginInfo;
import com.liy.framework.common.utils.ContextHandler;

import java.util.Locale;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.web.servlet.support.RequestContextUtils;

public class SupportController {
    protected static Logger log = LoggerFactory.getLogger(SupportController.class);

    @Autowired
    protected HttpServletRequest request;  // 自动注入当前 请求对象实例

    @Autowired
    protected HttpServletResponse response; // 自动注入当前 响应对象实例


    @Autowired
    private MessageSource messageSource;


    public SupportController() {
    }

    protected LoginInfo getLoginUser() {
        return ContextHandler.getLoginUser();
    }

    // 获取当前登录的用户的车站信息
    protected String getStationNo() {
        return ContextHandler.getLoginUser().getStationNo();
    }

    // 获取当前登录的用户的车站信息
    protected String getLoginUserId() {
        return this.getLoginUser().getId();
    }

    protected String getJwtToken() {
        return ContextHandler.getJwtToken();
    }

    protected String getAuthorization() {
        return ContextHandler.getAuthKey();
    }

    protected Object getCurrentAttr(String key) {
        return ContextHandler.get(key);
    }

    protected String getRequestParameter(String key) {
        return this.request.getParameter(key);
    }

    protected String getMessage(String key) {
        Locale locale = RequestContextUtils.getLocale(this.request);
        return this.messageSource.getMessage(key, (Object[])null, locale);
    }
}
